CSharpTest.Net
BTreeDictionary<TKey,TValue> Constructor(IComparer<TKey>)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class > BTreeDictionary<TKey,TValue> Constructor : BTreeDictionary<TKey,TValue> Constructor(IComparer<TKey>)

comparer

Glossary Item Box

Constructs a BTreeList instance.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal comparer As IComparer(Of TKey) _
)
C# 
public BTreeDictionary<TKey,TValue>( 
   IComparer<TKey> comparer
)

Parameters

comparer

Example

Library/Library.Test/TestBTreeDictionary.cs

C#Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer);
for (int i = 0; i < 100; i++)
    Assert.IsTrue(data.TryAdd(i, i.ToString()));

Assert.AreEqual(50, new List<KeyValuePair<int, string>>(data.EnumerateFrom(50)).Count);
Assert.AreEqual(25, new List<KeyValuePair<int, string>>(data.EnumerateFrom(75)).Count);

for (int i = 0; i < 100; i++)
{
    int first = -1;
    foreach (KeyValuePair<int, string> kv in data.EnumerateFrom(i))
    {
        first = kv.Key;
        break;
    }
    Assert.AreEqual(i, first);
}
VB.NETCopy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer)
Dim i As Integer = 0
While i < 100
    Assert.IsTrue(data.TryAdd(i, i.ToString()))
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Assert.AreEqual(50, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(50)).Count)
Assert.AreEqual(25, New List(Of KeyValuePair(Of Integer, String))(data.EnumerateFrom(75)).Count)

Dim i As Integer = 0
While i < 100
    Dim first As Integer = -1
    For Each kv As KeyValuePair(Of Integer, String) In data.EnumerateFrom(i)
        first = kv.Key
        Exit For
    Next
    Assert.AreEqual(i, first)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys